// 用户相关的接口文件
import type { UserType, SendType, UserInfo } from '@/types/user'
import { request } from '@/utils/request'
// 手机号+密码的登录接口
export const reqLoginByPassword = (mobile: string, password: string) => {
  return request<UserType>('login/password', 'POST', { mobile, password })
}

// 获取短信验证码(login登录)
// login登录register注册changeMobile更换手机号forgetPassword找回密码,bindMobile绑定三方登录，区分验证码
export const reqSendCode = (mobile: string, type: SendType) =>
  request('code', 'GET', { mobile, type })

// 手机号验证码登录
export const reqLoginByCode = (mobile: string, code: string) => {
  return request<UserType>('login', 'post', { mobile, code })
}
// 获取用户信息
export const reqGetUserInfo = () => request<UserInfo>('patient/myUser')

// 携带openID验证
export const reqLoginByQQ = (data: { openId: string; source: string }) =>
  request<UserType>('login/thirdparty', 'post', data)
// 绑定手机号+qq三方登录
export const reqBinding = (data: {
  mobile: string
  code: string
  openId: string
}) => request<UserType>('login/binding', 'POST', data)
